<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>使用VuePress搭建vue组件库 | XiaoZhang’s Blog</title><meta name="keywords" content="文档,vue,vue组件库"><meta name="author" content="XiaoZhang,邮箱"><meta name="copyright" content="XiaoZhang"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="description" content="为什么要使用VuePress？社区里面有很多优秀的文档工具可以供我们前端程序员选择，例如Gitbook、Hexo、Docusaurus。就个人使用而言，体验最好的文档工具是Docusaurus。  Docusaurus具有配置简单，目录结构合理、Markdown渲染配置灵活等一系列的优点。但对于Vue的开发者不太友好的是，Docusaurus是基于React的，如果你想在其中使用Vue的写法和渲染">
<meta property="og:type" content="article">
<meta property="og:title" content="使用VuePress搭建vue组件库">
<meta property="og:url" content="https://zhang_shaolong.gitee.io/posts/a2b7.html">
<meta property="og:site_name" content="XiaoZhang’s Blog">
<meta property="og:description" content="为什么要使用VuePress？社区里面有很多优秀的文档工具可以供我们前端程序员选择，例如Gitbook、Hexo、Docusaurus。就个人使用而言，体验最好的文档工具是Docusaurus。  Docusaurus具有配置简单，目录结构合理、Markdown渲染配置灵活等一系列的优点。但对于Vue的开发者不太友好的是，Docusaurus是基于React的，如果你想在其中使用Vue的写法和渲染">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://zhang_shaolong.gitee.io/img/assist/image2.png">
<meta property="article:published_time" content="2021-11-02T08:03:00.000Z">
<meta property="article:modified_time" content="2022-03-22T14:18:32.045Z">
<meta property="article:author" content="XiaoZhang">
<meta property="article:tag" content="文档">
<meta property="article:tag" content="vue">
<meta property="article:tag" content="vue组件库">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zhang_shaolong.gitee.io/img/assist/image2.png"><link rel="shortcut icon" href="/img/dvoe.png"><link rel="canonical" href="https://zhang_shaolong.gitee.io/posts/a2b7"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?ffcbb436e2f4b0326f38f622b85c0f07";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '使用VuePress搭建vue组件库',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-03-22 22:18:32'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><div class="aplayer" data-id="7031037814" data-server="netease" data-type="playlist" data-fixed="true" data-listFolded="false" data-order="random" data-preload="none"></div><link rel="stylesheet" href="https://cdn.bootcss.com/aplayer/1.10.1/APlayer.min.css"><script src="https://cdn.bootcss.com/aplayer/1.10.1/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js"></script><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    document.addEventListener('pjax:complete', detectApple)})(window)</script><link rel="stylesheet" href="/css/bg.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/static-butterfly/dist/css/index.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://zhang_shaolong.gitee.io/css/bg.css"><div id="aplayer"></div><!--script(src="https://cdn.jsdelivr.net/gh/radium-bit/res@master/live2d/autoload.js" async)--><!--script(src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js" async)--><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="XiaoZhang’s Blog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.jpeg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">25</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">20</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/navigation/"><i class="fa-fw fas fa-map"></i><span> 导航</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 博客</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-camera"></i><span> 相册</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/bb/"><i class="fa-fw fas fa-bomb"></i><span> 动态</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友人帐</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/my-profile/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/../img/assist/image2.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">XiaoZhang’s Blog</a><div id="he-plugin-simple"></div></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/navigation/"><i class="fa-fw fas fa-map"></i><span> 导航</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 博客</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-camera"></i><span> 相册</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/bb/"><i class="fa-fw fas fa-bomb"></i><span> 动态</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友人帐</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/my-profile/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">使用VuePress搭建vue组件库</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-11-02T08:03:00.000Z" title="发表于 2021-11-02 16:03:00">2021-11-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-22T14:18:32.045Z" title="更新于 2022-03-22 22:18:32">2022-03-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="使用VuePress搭建vue组件库"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="为什么要使用VuePress？"><a href="#为什么要使用VuePress？" class="headerlink" title="为什么要使用VuePress？"></a>为什么要使用VuePress？</h2><p>社区里面有很多优秀的文档工具可以供我们前端程序员选择，例如Gitbook、Hexo、Docusaurus。就个人使用而言，体验最好的文档工具是<a target="_blank" rel="noopener" href="https://www.docusaurus.cn/">Docusaurus</a>。</p>
<p><img src="/posts/a2b7.htm/assist/image1.png"></p>
<p>Docusaurus具有配置简单，目录结构合理、Markdown渲染配置灵活等一系列的优点。但对于Vue的开发者不太友好的是，Docusaurus是基于React的，如果你想在其中使用Vue的写法和渲染Vue组件会变得十分困难。所以如果你是Vue的开发者，在编写Vue相关组件文档的时候，个人还是推荐使用官方的VuePress。</p>
<p>下面的教程会使用VuePress生成类似Element的组件文档库，包括Vue组件展示、示例代码展示、自定义主题等常用功能。</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><ol>
<li>创建项目 vuepress-element-doc<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir vuepress-element-doc &amp;&amp; cd vuepress-element-doc</span><br></pre></td></tr></table></figure></li>
<li> 初始化npm包管理并在 package.json 中新增脚本<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm init -y</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">// package.json</span><br><span class="line">&quot;scripts&quot;: &#123;</span><br><span class="line">  &quot;dev&quot;: &quot;vuepress dev docs&quot;,</span><br><span class="line">  &quot;build&quot;: &quot;vuepress build docs&quot;</span><br><span class="line">&#125;,</span><br></pre></td></tr></table></figure></li>
<li>安装 VuePress + Element<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install vuepress element-ui --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>
因为我们要做的是Element的组件文档页，所有这里顺便安装一下Element。你如果需要展示你自己的组件库，那么安装或引人自己的组件库的js和css即可。</li>
</ol>
<h2 id="创建首页"><a href="#创建首页" class="headerlink" title="创建首页"></a>创建首页</h2><h4 id="新建首页-md文件"><a href="#新建首页-md文件" class="headerlink" title="新建首页.md文件"></a>新建首页.md文件</h4><p>新建 docs/README.md </p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">home: true</span><br><span class="line">heroImage: https://artice-code-1258339218.cos.ap-beijing.myqcloud.com/vuepress/element-index.png</span><br><span class="line">heroText: Element</span><br><span class="line">features:</span><br><span class="line">- title: 一致性 Consistency</span><br><span class="line">  details: 与现实生活一致：与现实生活的流程、逻辑保持一致，遵循用户习惯的语言和概念</span><br><span class="line">- title: 反馈 Feedback</span><br><span class="line">  details: 通过界面样式和交互动效让用户可以清晰的感知自己的操作</span><br><span class="line">- title: 效率 Efficiency</span><br><span class="line">  details: 界面简单直白，让用户快速识别而非回忆，减少用户记忆负担。</span><br><span class="line">footer: by饿了么</span><br><span class="line">---</span><br><span class="line"></span><br><span class="line">### 设计原则</span><br><span class="line"></span><br><span class="line">&lt;div style=&quot;display:flex;justify-content: space-between;padding-bottom:40px&quot;&gt;</span><br><span class="line">  &lt;div style=&quot;display: flex;flex-direction: column;align-items: center;&quot;&gt;</span><br><span class="line">    &lt;img style=&quot;width:100px&quot; src=&quot;https://artice-code-1258339218.cos.ap-beijing.myqcloud.com/vuepress/consistency.png&quot; alt=&quot;一致性&quot;&gt;</span><br><span class="line">    &lt;p style=&quot;margin:5px&quot;&gt;一致性&lt;/p&gt;</span><br><span class="line">    &lt;p style=&quot;margin:0px;font-size: 12px;color:#666&quot;&gt;Consistency&lt;/p&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">  &lt;div style=&quot;display: flex;flex-direction: column;align-items: center;&quot;&gt;</span><br><span class="line">    &lt;img style=&quot;width:100px&quot; src=&quot;https://artice-code-1258339218.cos.ap-beijing.myqcloud.com/vuepress/feedback.png&quot; alt=&quot;反馈&quot;&gt;</span><br><span class="line">    &lt;p style=&quot;margin:5px&quot;&gt;反馈&lt;/p&gt;</span><br><span class="line">    &lt;p style=&quot;margin:0px;font-size: 12px;color:#666&quot;&gt; Feedback&lt;/p&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">  &lt;div style=&quot;display: flex;flex-direction: column;align-items: center;&quot;&gt;</span><br><span class="line">    &lt;img style=&quot;width:100px&quot; src=&quot;https://artice-code-1258339218.cos.ap-beijing.myqcloud.com/vuepress/efficiency.png&quot; alt=&quot;效率&quot;&gt;</span><br><span class="line">    &lt;p style=&quot;margin:5px&quot;&gt;效率&lt;/p&gt;</span><br><span class="line">    &lt;p style=&quot;margin:0px;font-size: 12px;color:#666&quot;&gt;Efficiency&lt;/p&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">  &lt;div style=&quot;display: flex;flex-direction: column;align-items: center;&quot;&gt;</span><br><span class="line">    &lt;img style=&quot;width:100px&quot; src=&quot;https://artice-code-1258339218.cos.ap-beijing.myqcloud.com/vuepress/controllability%20%20.png&quot; alt=&quot;可控&quot;&gt;</span><br><span class="line">    &lt;p style=&quot;margin:5px&quot;&gt;可控&lt;/p&gt;</span><br><span class="line">    &lt;p style=&quot;margin:0px;font-size: 12px;color:#666&quot;&gt;Controllability&lt;/p&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/div&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>这个README.md中一共有三种语法：</p>
<ol>
<li>YAML: 顶部以 — 包裹起来的是YAML语法的Front Matter，这个语法必须位于.md的顶部，是可选的。</li>
<li>Markdown: 其中 ### 设计原则  部分是Markdown语法，相信大家都很熟悉。</li>
<li>HTML: 最后是我们熟悉的HTML语法，总所周知，在 .md 中是可以使用HTML语法的。</li>
</ol>
<blockquote>
<p>备注：docs/README.md中的图片地址是放到OSS上的地址，因为这样更方便使用。当然你也可以使用本地的公共文件，具体见Vuepress/静态资源/公共文件。</p>
</blockquote>
<h4 id="创建配置文件"><a href="#创建配置文件" class="headerlink" title="创建配置文件"></a>创建配置文件</h4><p>新建 docs/.vuepress/config.js ，填入基本的配置信息。注意，这个文件是VuePress最核心的一个文件，有着丰富的配置项。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">module.exports = &#123;</span><br><span class="line">  theme: &#x27;&#x27;,</span><br><span class="line">  title: &#x27;VuePress + Element&#x27;,</span><br><span class="line">  description: &#x27;VuePress搭建Element的组件库文档教程示例代码&#x27;,</span><br><span class="line">  base: &#x27;/&#x27;,</span><br><span class="line">  port: &#x27;8080&#x27;,</span><br><span class="line">  themeConfig: &#123;&#125;,</span><br><span class="line">  head: [],</span><br><span class="line">  plugins: [],</span><br><span class="line">  markdown: &#123;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="启动项目"><a href="#启动项目" class="headerlink" title="启动项目"></a>启动项目</h4><p>使用命令运行VuePress，查看效果</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm run dev</span><br></pre></td></tr></table></figure>
<p>浏览器访问 localhost:8080 ，如果没有意外，我相信你已经能够在页面上看到如下的效果了，这个页面就是我们在README.md 这个文件中所编写的YAML + Markdown + HTML的整体效果。<br><img src="/posts/a2b7.htm/assist/image2.png"></p>
<h4 id="配置组件页文档的侧边栏"><a href="#配置组件页文档的侧边栏" class="headerlink" title="配置组件页文档的侧边栏"></a>配置组件页文档的侧边栏</h4><p>在/docs/.vuepress/config.js 中配置顶部导航栏的配置字段 themeConfig.sidebar。代码如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">module.exports = &#123;</span><br><span class="line">  theme: &#x27;&#x27;,</span><br><span class="line">  title: &#x27;VuePress + Element&#x27;,</span><br><span class="line">  description: &#x27;VuePress搭建Element的组件库文档教程示例代码&#x27;,</span><br><span class="line">  base: &#x27;/&#x27;,</span><br><span class="line">  port: &#x27;8080&#x27;,</span><br><span class="line">  themeConfig: &#123;</span><br><span class="line">    nav: [</span><br><span class="line">      &#123;</span><br><span class="line">        text: &#x27;首页&#x27;,</span><br><span class="line">        link: &#x27;/&#x27;</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        text: &#x27;组件&#x27;,</span><br><span class="line">        link: &#x27;/comps/&#x27;</span><br><span class="line">      &#125;</span><br><span class="line">    ],</span><br><span class="line">    sidebar: &#123; // 配置侧边栏部分</span><br><span class="line">      &#x27;/comps/&#x27;: [&#x27;/comps/&#x27;, &#x27;/comps/select.md&#x27;]</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  head: [],</span><br><span class="line">  plugins: [],</span><br><span class="line">  markdown: &#123;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="/posts/a2b7.htm/assist/image3.png"></p>
<h2 id="组件展示效果实现"><a href="#组件展示效果实现" class="headerlink" title="组件展示效果实现"></a>组件展示效果实现</h2><p>可是到目前为止，我们还没有引入Element的组件部分，既然是一个组件库，我们自然希望实现像Element这样，上面有组件的展示，下面是示例的代码。这一部分我们就来看看如何实现这个效果吧<br><img src="/posts/a2b7.htm/assist/image4.png"></p>
<h4 id="安装Demo插件"><a href="#安装Demo插件" class="headerlink" title="安装Demo插件"></a>安装Demo插件</h4><p>这里我们会使用到一个 vuepress-plugin-demo-container 这个插件，使用以下命令安装</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install vuepress-plugin-demo-container --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>
<p>然后在/docs/.vuepress/config.js文件中配置上该插件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">module.exports = &#123;</span><br><span class="line"> 	// ...</span><br><span class="line">  plugins: [&#x27;demo-container&#x27;], // 配置插件</span><br><span class="line">  markdown: &#123;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="认识enhanceApp-js"><a href="#认识enhanceApp-js" class="headerlink" title="认识enhanceApp.js"></a>认识enhanceApp.js</h4><p>你有没有想过我们平时在项目里面使用Element，需要在 app.js 中引入Element，并调用 Vue.use(Element) 才能够在Vue中使用Element的组件，那么我们如果想在VuePress中使用Element，我们需要去哪里编写这段代码呢？</p>
<p>此时我们需要认识一个新的文件enhanceApp.js，它算是VuePress中仅此于config.js 第二重要的文件了，当你想做一些Vue应用级别的配置时，就需要在这个文件里面配置。让我们在新建该文件吧：/docs/.vuepress/enhanceApp.js。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">import ElementUI from &#x27;element-ui&#x27;;</span><br><span class="line">import &#x27;element-ui/lib/theme-chalk/index.css&#x27;;</span><br><span class="line"></span><br><span class="line">export default async (&#123;</span><br><span class="line">  Vue</span><br><span class="line">&#125;) =&gt; &#123;</span><br><span class="line">  if (typeof process === &#x27;undefined&#x27;) &#123;</span><br><span class="line">    Vue.use(ElementUI)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="引入Element组件"><a href="#引入Element组件" class="headerlink" title="引入Element组件"></a>引入Element组件</h5><p>接下来我们在刚才创建的/docs/comps/select.md中使用Element试试看吧。使用下面的内容替换原有的内容吧。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"># Select 选择器</span><br><span class="line"></span><br><span class="line">当选项过多时，使用下拉菜单展示并选择内容。</span><br><span class="line"></span><br><span class="line">## 基本用法</span><br><span class="line"></span><br><span class="line">适用广泛的基础单选</span><br><span class="line"></span><br><span class="line">::: demo 适用广泛的基础单选</span><br><span class="line">```html</span><br><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;el-select v-model=&quot;value&quot; placeholder=&quot;请选择&quot;&gt;</span><br><span class="line">    &lt;el-option</span><br><span class="line">      v-for=&quot;item in options&quot;</span><br><span class="line">      :key=&quot;item.value&quot;</span><br><span class="line">      :label=&quot;item.label&quot;</span><br><span class="line">      :value=&quot;item.value&quot;&gt;</span><br><span class="line">    &lt;/el-option&gt;</span><br><span class="line">  &lt;/el-select&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line">  export default &#123;</span><br><span class="line">    data() &#123;</span><br><span class="line">      return &#123;</span><br><span class="line">        options: [&#123;</span><br><span class="line">          value: &#x27;选项1&#x27;,</span><br><span class="line">          label: &#x27;黄金糕&#x27;</span><br><span class="line">        &#125;, &#123;</span><br><span class="line">          value: &#x27;选项2&#x27;,</span><br><span class="line">          label: &#x27;双皮奶&#x27;</span><br><span class="line">        &#125;],</span><br><span class="line">        value: &#x27;&#x27;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line">` ` `</span><br><span class="line">:::</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>如果一切顺利的话，我相信你此时应该能够看到以下的效果了：<br><img src="/posts/a2b7.htm/assist/image5.png"></p>
<blockquote>
<p>Node.js的版本不宜过高，会出现不兼容问题，建议v12.22.7</p>
</blockquote>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:邮箱">XiaoZhang</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://zhang_shaolong.gitee.io/posts/a2b7.html">https://zhang_shaolong.gitee.io/posts/a2b7.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://zhang_shaolong.gitee.io" target="_blank">XiaoZhang’s Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E6%96%87%E6%A1%A3/">文档</a><a class="post-meta__tags" href="/tags/vue/">vue</a><a class="post-meta__tags" href="/tags/vue%E7%BB%84%E4%BB%B6%E5%BA%93/">vue组件库</a></div><div class="post_share"><div class="social-share" data-image="/../img/assist/image2.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/a76d.html"><img class="prev-cover" src="/../cover/think.jpeg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">总结（10.30）</div></div></a></div><div class="next-post pull-right"><a href="/posts/2cb6.html"><img class="next-cover" src="https://tva2.sinaimg.cn/large/87c01ec7gy1frmmnduv7lj21hc0u0x6p.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">总结（11,6）</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/c346.html" title="markdown编辑文档使用教程"><img class="cover" src="/../cover/markdown.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-21</div><div class="title">markdown编辑文档使用教程</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/avatar.jpeg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">XiaoZhang</div><div class="author-info__description">彼方尚有荣光在！！！ </div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">25</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">20</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/zhang_shaolong"><i class="fab fa-github-alt"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">有朋自远方来，不亦乐乎！</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E4%BD%BF%E7%94%A8VuePress%EF%BC%9F"><span class="toc-number">1.</span> <span class="toc-text">为什么要使用VuePress？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E9%A6%96%E9%A1%B5"><span class="toc-number">3.</span> <span class="toc-text">创建首页</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%96%B0%E5%BB%BA%E9%A6%96%E9%A1%B5-md%E6%96%87%E4%BB%B6"><span class="toc-number">3.0.1.</span> <span class="toc-text">新建首页.md文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">3.0.2.</span> <span class="toc-text">创建配置文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E9%A1%B9%E7%9B%AE"><span class="toc-number">3.0.3.</span> <span class="toc-text">启动项目</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E7%BB%84%E4%BB%B6%E9%A1%B5%E6%96%87%E6%A1%A3%E7%9A%84%E4%BE%A7%E8%BE%B9%E6%A0%8F"><span class="toc-number">3.0.4.</span> <span class="toc-text">配置组件页文档的侧边栏</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BB%84%E4%BB%B6%E5%B1%95%E7%A4%BA%E6%95%88%E6%9E%9C%E5%AE%9E%E7%8E%B0"><span class="toc-number">4.</span> <span class="toc-text">组件展示效果实现</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%89%E8%A3%85Demo%E6%8F%92%E4%BB%B6"><span class="toc-number">4.0.1.</span> <span class="toc-text">安装Demo插件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86enhanceApp-js"><span class="toc-number">4.0.2.</span> <span class="toc-text">认识enhanceApp.js</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%BC%95%E5%85%A5Element%E7%BB%84%E4%BB%B6"><span class="toc-number">4.0.2.1.</span> <span class="toc-text">引入Element组件</span></a></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/89a6.html" title="总结(1.16)"><img src="https://api.ixiaowai.cn/gqapi/gqapi.php" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="总结(1.16)"/></a><div class="content"><a class="title" href="/posts/89a6.html" title="总结(1.16)">总结(1.16)</a><time datetime="2022-01-16T13:51:00.000Z" title="发表于 2022-01-16 21:51:00">2022-01-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/488c.html" title="JS函数柯里化"><img src="/../cover/currying.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JS函数柯里化"/></a><div class="content"><a class="title" href="/posts/488c.html" title="JS函数柯里化">JS函数柯里化</a><time datetime="2021-12-07T06:37:00.000Z" title="发表于 2021-12-07 14:37:00">2021-12-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/2f90.html" title="总结(12.5)"><img src="https://tva4.sinaimg.cn/large/87c01ec7gy1frmmw9573mj21kw0w0npk.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="总结(12.5)"/></a><div class="content"><a class="title" href="/posts/2f90.html" title="总结(12.5)">总结(12.5)</a><time datetime="2021-12-05T03:17:00.000Z" title="发表于 2021-12-05 11:17:00">2021-12-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/dc34.html" title="Socket.IO使用"><img src="/../cover/socket.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Socket.IO使用"/></a><div class="content"><a class="title" href="/posts/dc34.html" title="Socket.IO使用">Socket.IO使用</a><time datetime="2021-11-30T01:19:00.000Z" title="发表于 2021-11-30 09:19:00">2021-11-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/b9e7e805.html" title="总结(11.27)"><img src="https://tva1.sinaimg.cn/large/0060lm7Tly1ftg6oqfp3aj318g0p0k4h.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="总结(11.27)"/></a><div class="content"><a class="title" href="/posts/b9e7e805.html" title="总结(11.27)">总结(11.27)</a><time datetime="2021-11-27T08:55:00.000Z" title="发表于 2021-11-27 16:55:00">2021-11-27</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'eHF7sUaBksaicGG9E3R7cdnJ-gzGzoHsz',
      appKey: 'nkwWdcso9uIl84CMuiYeg94T',
      placeholder: 'ヾﾉ≧∀≦)o来啊，快活啊!',
      avatar: 'monsterid',
      meta: 'nick,mail,QQ'.split(','),
      pageSize: '12',
      lang: 'zh-CN',
      recordIP: false,
      serverURLs: '',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: true,
      path: window.location.pathname,
      requiredFields: ["nick,mail"],
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/gh/HCLonely/Valine@latest/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><canvas id="universe"></canvas><script src="https://myhkw.cn/player/js/jquery.min.js" type="text/javascript"></script><script defer src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/js/star.js"></script><script async src="/js/diytitle.js"></script><script async data-pjax src="/js/randombg.js"></script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script async src="/js/weather.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@latest/source/js/issues.min.js"></script><script src="/js/universe.js"></script><script src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script> $(".category-list-count").prepend("<i class=\"fas fa-book\"></i>");</script><script> $(".category-list-item").eq(0).insertAfter($(".gallery-group-name").eq(0))</script><script> $(".category-list-item").eq(1).insertAfter($(".gallery-group-name").eq(1))</script><script> $(".category-list-item").eq(2).insertAfter($(".gallery-group-name").eq(2))</script><script> $(".category-list-item").eq(3).insertAfter($(".gallery-group-name").eq(3))</script><script> $(".category-list-item").eq(4).insertAfter($(".gallery-group-name").eq(4))</script><script> $(".category-list-item").eq(5).insertAfter($(".gallery-group-name").eq(5))</script><script> $(".category-list-item a").hide();</script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="富强,民主,文明,和谐,自由,平等,公正,法治,爱国,敬业,诚信,友善" data-fontsize="18px" data-random="true" async="async"></script><script src="//code.tidio.co/mxavk34b68alwnegypahsbiwew7digod.js" async="async"></script><script>function onTidioChatApiReady() {
  window.tidioChatApi.hide();
  window.tidioChatApi.on("close", function() {
    window.tidioChatApi.hide();
  });
}
if (window.tidioChatApi) {
  window.tidioChatApi.on("ready", onTidioChatApiReady);
} else {
  document.addEventListener("tidioChat-ready", onTidioChatApiReady);
}

var chatBtnFn = () => {
  document.getElementById("chat_btn").addEventListener("click", function(){
    window.tidioChatApi.show();
    window.tidioChatApi.open();
  });
}
chatBtnFn()
</script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start -->
  <script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/hexo-github-calendar@1.21/hexo_githubcalendar.js"></script>
  <script data-pjax>
        function GithubCalendarConfig(){
            var git_githubapiurl ="https://python-gitee-calendar-api.vercel.app/api?zhang_shaolong";
            var git_color =['#ebedf0', '#f1f8ff', '#dbedff', '#c8e1ff', '#79b8ff', '#2188ff', '#0366d6', '#005cc5', '#044289', '#032f62', '#05264c'];
            var git_user ="zhang_shaolong";
            var parent_div_git = document.getElementById('recent-posts');
            var git_div_html = '<div class="recent-post-item" style="width:100%;height:auto;padding:10px;"><div id="github_loading" style="width:10%;height:100%;margin:0 auto;display: block"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"><path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform></path></svg></div><div id="github_container"></div></div>';
            if(parent_div_git && location.pathname =='/'){
                console.log('已挂载github calendar')
                // parent_div_git.innerHTML=git_div_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",git_div_html) // 有报错，但不影响使用(支持pjax跳转)
            };
            GithubCalendar(git_githubapiurl,git_color,git_user)
        }
        if(document.getElementById('recent-posts')){
            GithubCalendarConfig()
        }
    </script>
    <style>#github_container{min-height:280px}@media screen and (max-width:650px) {#github_container{background-image:;min-height:0px}}</style>
    <style></style><script data-pjax>
  function butterfly_footer_beautify_injector_config(){
    var parent_div_git = document.getElementById('footer-wrap');
    var item_html = '<div id="workboard"></div><div id="ghbdages" style="overflow:hidden;max-height:90px;height:auto;text-align:center;margin-top:10px"><div class="swiper-wrapper"><div class="swiper-slide"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" title="博客框架为Hexo_v5.4.0"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" title="主题版本Butterfly_v3.8.2"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt=""/></a><a class="github-badge" target="_blank" href="https://www.jsdelivr.com/" style="margin-inline:5px" title="本站使用JsDelivr为静态资源提供CDN加速"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&amp;logo=jsDelivr" alt=""/></a></div><div class="swiper-slide"><a class="github-badge" target="_blank" href="https://github.com/" style="margin-inline:5px" title="本站项目由Github托管"><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&amp;logo=GitHub" alt=""/></a><a class="github-badge" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt=""/></a></div></div></div><style>a.github-badge:hover:before {display:none}</style>';
    console.log('已挂载butterfly_footer_beautify')
    parent_div_git.insertAdjacentHTML("beforeend",item_html)
    }
  var elist = '/about/'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_footer_beautify_injector_config();
  }
  else if (epage === cpage){
    butterfly_footer_beautify_injector_config();
  }
  </script><script async src="/js/runtime.js"></script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script><script defer data-pjax src="https://unpkg.zhimg.com/hexo-butterfly-footer-beautify/lib/swiperbdage_init.min.js"></script><script data-pjax>
  function butterfly_swiper_injector_config(){
    var parent_div_git = document.getElementById('recent-posts');
    var item_html = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/dc34.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="../cover/socket.webp" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2021-11-30</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/dc34.html&quot;);" href="javascript:void(0);" alt="">Socket.IO使用</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/dc34.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/bf72.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="../img/垂直.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2021-10-24</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/bf72.html&quot;);" href="javascript:void(0);" alt="">一个盒子垂直水平居中有哪些方法？</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/bf72.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/a2b7.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="../img/assist/image2.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2021-11-02</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/a2b7.html&quot;);" href="javascript:void(0);" alt="">使用VuePress搭建vue组件库</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/a2b7.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/213d.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="../cover/business.jpg" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2021-05-12</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/213d.html&quot;);" href="javascript:void(0);" alt="">双飞翼布局和圣杯布局</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/213d.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/3079.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="https://api.ixiaowai.cn/gqapi/gqapi.php" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2021-04-03</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/3079.html&quot;);" href="javascript:void(0);" alt="">盒模型</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/3079.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载butterfly_swiper')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'undefined'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_swiper_injector_config();
  }
  else if (epage === cpage){
    butterfly_swiper_injector_config();
  }
  </script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script><script defer data-pjax src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper_init.js"></script><!-- hexo injector body_end end --></body></html>